package datastruct;

import java.util.HashSet;
import java.util.Set;

public class FindNumsAppearOnce {

    public static void main(String[] args) {
        System.out.println(FindNumsAppearOnce(new int[]{1, 4, 1, 6}));
    }

    public static int[] FindNumsAppearOnce (int[] array) {
        // write code here
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < array.length; i++){
            if (set.contains(array[i])){
                set.remove(array[i]);
            } else {
                set.add(array[i]);
            }
        }
        int[] res = new int[2];
        int index = 0;
        for (Integer integer : set) {
            res[index] = integer;
            index++;
        }
        if (res[0] > res[1]){
            int tmp = res[0];
            res[0] = res[1];
            res[1] = tmp;
        }
        return res;
    }
}
